public class Solve {
    // 把数字翻译成字符串
    // https://www.nowcoder.com/practice/046a55e6cd274cffb88fc32dba695668?tpId=295&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3DSQL%25E7%25AF%2587%26topicId%3D295
    public int solve (String nums) {
        // write code here
        // dp[i]表示[0,i]之间有多少种翻译方式
        // dp[i] = dp[i-1] +
        // (nums.subString(i-2, i+1).compareTo("26") <= 0 ? dp[i-2] : 0)
        nums = "00" + nums;
        int len = nums.length();
        int[] dp = new int[len];
        dp[0] = dp[1] = 1;
        for (int i = 2; i < len; i++) {
            // 单个字符必须符合在[1,26]之间
            if (nums.charAt(i) >= '1' && nums.charAt(i - 1) <= '9') {
                dp[i] = dp[i-1];
            }
            int num = Integer.parseInt(nums.substring(i-1,i+1));
            // 两个字符必须保证在[10,26]之间，01、02不符合
            if (num >= 10 && num <= 26) {
                dp[i] += dp[i-2];
            }
        }
        return dp[len-1];
    }

    public static void main(String[] args) {
        String nums = "72910721221427251718216239162221131917242";
        Solve solve = new Solve();
        System.out.println(solve.solve(nums));
    }
}
